<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Installing the MongoDB PHP Driver with PECL</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mongodb.installation.html">« 安装</a></li>
      <li style="float: right;"><a href="mongodb.installation.homebrew.html">Installing the MongoDB PHP Driver on macOS with Homebrew »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="mongodb.installation.html">安装</a></li>
    <li>Installing the MongoDB PHP Driver with PECL</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mongodb.installation.pecl" class="section">
  <h2 class="title">Installing the MongoDB PHP Driver with PECL</h2>

  <p class="para">
   安装此 PECL 扩展相关的信息可在手册中标题为
<a href="install.pecl.html" class="link">PECL
扩展的安装</a>章节中找到。更多信息如新的发行版本、下载、源文件、
维护人员信息及变更日志等，都在此处：
   <a href="https://pecl.php.net/package/mongodb" class="link external">&raquo;&nbsp;https://pecl.php.net/package/mongodb</a>
  </p>

  <p class="para">
   Linux, Unix, and macOS users may run the following command to install the
   driver:
   <div class="example-contents">
<div class="shellcode"><pre class="shellcode">$ sudo pecl install mongodb</pre>
</div>
   </div>

  </p>

  <p class="para">
   If your system has multiple version of PHP installed (e.g. macOS default,
   Homebrew, <a href="https://www.apachefriends.org/" class="link external">&raquo;&nbsp;XAMPP</a>), note that each
   version of PHP has its own <a href="install.pecl.html" class="link">pecl</a>
   command and <var class="filename">php.ini</var> file(s). Additionally, each PHP environments (e.g.
   CLI, web) may use separate <var class="filename">php.ini</var> files.
  </p>

  <p class="para">
   Installing the driver via PECL will use bundled versions of
   <a href="https://github.com/mongodb/mongo-c-driver/tree/master/src/libbson" class="link external">&raquo;&nbsp;libbson</a> and
   <a href="https://github.com/mongodb/mongo-c-driver" class="link external">&raquo;&nbsp;libmongoc</a> and attempt to
   automatically configure them.
  </p>

  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    If the build process fails to find an SSL library, check that the
    development packages (e.g. <code class="literal">libssl-dev</code>) and
    <a href="https://en.wikipedia.org/wiki/Pkg-config" class="link external">&raquo;&nbsp;pkg-config</a> are both
    installed. If that does not resolve the problem, consider using the
    <a href="mongodb.installation.manual.html" class="link">manual installation</a>
    process.
   </span>
  </p></blockquote>

  <p class="para">
   Finally, add the following line to the <var class="filename">php.ini</var> file for each environment
   in which you intend to use the driver:
   <div class="example-contents">
<div class="inicode"><pre class="inicode">extension=mongodb.so</pre>
</div>
   </div>

  </p>
 </div></div></div></body></html>